/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.wdm.beans;

import java.io.Serializable;
import javax.persistence.*;
import org.wdm.beans.points.Point;

/**
 *
 * @author thanasis
 */
@Entity
public class Crime implements Serializable, Comparable {
    private String category;
    private String location_type;
    private String yearMonth;
    
    @OneToOne(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    private Point cords;
    private String streetId;
    private String streetName;
    private String context;
    
    @Id
    private String id;

    public Crime() {
        cords = new Point();
    }

    public String getCategory() {
        return category;
    }

    public String getContext() {
        return context;
    }

    public String getId() {
        return id;
    }

    public double getLatitude() {
        return cords.getLatitude();
    }

    public String getLocation_type() {
        return location_type;
    }

    public double getLongitude() {
        return cords.getLongitude();
    }

    public String getMonth() {
        return yearMonth;
    }

    public String getStreetId() {
        return streetId;
    }

    public String getStreetName() {
        return streetName;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setLatitude(double latitude) {
        this.cords.setLatitude(latitude);
    }

    public void setLocation_type(String location_type) {
        this.location_type = location_type;
    }

    public void setLongitude(double longitude) {
        this.cords.setLongitude(longitude);
    }

    public void setMonth(String month) {
        this.yearMonth = month;
    }

    public void setStreetId(String steetId) {
        this.streetId = steetId;
    }

    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    @Override
    public String toString() {
        return "category=" + category + ", location_type=" + location_type + ", month=" + yearMonth + ", longitude=" + cords.getLongitude() + ", latitude=" + cords.getLatitude() + ", steetId=" + streetId + ", streetName=" + streetName + ", context=" + context + ", id=" + id;
    }

    /**
     * @return the cords
     */
    public Point getCords() {
        return cords;
    }

    /**
     * @param cords the cords to set
     */
    public void setCords(Point cords) {
        this.cords = cords;
    }

    public int compareTo(Object o) {
        Crime other = (Crime) o;
        if(other.getId().equals(this.id)){
            return 0;
        } else{
            return -1;
        }
    }
}
